<link rel="stylesheet" href="<%- Virtual_Path.Static %>main/css/lib/bootstrap/css//bootstrap.min.css"/>
<link rel="stylesheet" href="<%- Virtual_Path.Static %>main/css/lib/bootstrap/css/bootstrap-theme.min.css"/>
<link rel="stylesheet" href="<%- Virtual_Path.Static %>main/css/entry-apply.css"/>

<div class="xiu-container">
    <div class="apply-wrap" id="j-yr-apply">
        <h1 class="app-tit">艺人申请入驻</h1>
        <!--进度步骤导航-->
        <div class="apply-step clearfix">
            <ul class="progress-step-nav">
                <li><a href="javascript:;"><i>1</i>个人资料</a></li>
                <li class="active"><a href="javascript:;"><i>2</i>财务信息</a></li>
                <li><a href="javascript:;"><i>3</i>封面照片</a></li>
                <li><a href="javascript:;"><i>4</i>完成</a></li>
            </ul>
        </div>

        <!-- 进度步骤-->
        <div class="progress-step-cont">
            <div class="step-cont-outer">
                <div class="step-cont-inner">
                    <div class="step-cont-mod step-2">
                        <form class="form-horizontal">
                            <div class="form-group">
                                <div class="col-xs-8 form-group">
                                    <label for="" class="col-sm-2 control-label">开户人姓名</label>
                                    <div class="col-sm-5">
                                        <input type="text" class="form-control" placeholder="" name="Account_RealName">
                                    </div>
                                    <div class="col-sm-5">
                                        <p>（注释：与申请者本人姓名一致）</p>
                                    </div>
                                </div>

                            </div>

                            <div class="col-xs-8 form-group">
                                <label for="" class="col-sm-2 control-label">银行卡号</label>
                                <div class="col-sm-5">
                                    <input type="text" class="form-control" placeholder="" name="Account_CardNo">
                                </div>

                            </div>

                            <div class="col-xs-8 form-group">
                                <label for="" class="col-sm-2 control-label">开户银行</label>
                                <div class="col-sm-4">
                                    <select class="form-control" name="Account_BankName" id="J_Account_BankName">
                                    </select>
                                </div>
                            </div>
                            <div class="col-xs-8 form-group">
                                <label for="" class="col-sm-2 control-label">开户地</label>
                                <div class="col-sm-2">
                                    <select class="form-control" name="parent_id" id="region_parent">
                                        <option value="">--</option>
                                        <option value="北京">北京</option>
                                        <option value="上海">上海</option>
                                        <option value="天津">天津</option>
                                        <option value="重庆">重庆</option>
                                        <option value="浙江">浙江</option>
                                        <option value="黑龙江">黑龙江</option>
                                        <option value="辽宁">辽宁</option>
                                        <option value="四川">四川</option>
                                        <option value="安徽">安徽</option>
                                        <option value="福建">福建</option>
                                        <option value="甘肃">甘肃</option>
                                        <option value="广东">广东</option>
                                        <option value="广西">广西</option>
                                        <option value="贵州">贵州</option>
                                        <option value="海南">海南</option>
                                        <option value="河北">河北</option>
                                        <option value="河南">河南</option>
                                        <option value="山东">山东</option>
                                        <option value="湖北">湖北</option>
                                        <option value="湖南">湖南</option>
                                        <option value="吉林">吉林</option>
                                        <option value="江苏">江苏</option>
                                        <option value="江西">江西</option>
                                        <option value="内蒙古">内蒙古</option>
                                        <option value="青海">青海</option>
                                        <option value="山西">山西</option>
                                        <option value="陕西">陕西</option>
                                        <option value="西藏">西藏</option>
                                        <option value="新疆">新疆</option>
                                        <option value="云南">云南</option>
                                        <option value="香港">香港</option>
                                        <option value="澳门">澳门</option>
                                        <option value="台湾">台湾</option>
                                    </select>
                                </div>
                                <div class="col-sm-2">
                                    <select class="form-control" name="region_id" id="region_city">
                                        <option value="">--</option>
                                    </select>
                                </div>
                            </div>
                            <div class="col-xs-8 form-group">
                                <label for="" class="col-sm-2 control-label">开户地分行或支行名称</label>
                                <div class="col-sm-5">
                                    <input type="text" class="form-control" placeholder="" name="Account_BankFullName">
                                </div>
                                <div class="col-sm-5">
                                    <p class="form-control-static">（XX分行或XX县XX支行）</p>
                                </div>
                            </div>

                            <div class="col-xs-8 form-group">
                                <label for="" class="col-sm-2 control-label">身份证号码</label>
                                <div class="col-sm-5">
                                    <input type="text" class="form-control" placeholder="" name="IDCard">
                                </div>
                            </div>

                            <div class="col-xs-8 form-group">
                                <label for="" class="col-sm-2 control-label">身份证复印件</label>
                                <div class="col-sm-6">
                                    <div class="ucard-z">
                                        <input type="file" id="exampleInputFileA">
                                        <span id="J_Status_AImg">
                                            </span>
                                    </div>
                                    <div class="ucard-f">
                                        <input type="file" id="exampleInputFileB">
                                        <span id="J_Status_BImg">
                                            </span>
                                    </div>
                                </div>
                                <p class="help-block col-sm-8 col-sm-offset-2 clearfix">
                                    支持JPG,PNG格式,大小不超过2M <br/>
                                    请上传手持身份证照片<br/>
                                    <img src="<%- Virtual_Path.Static %>main/image/entry/anchor_example.png" alt="card"
                                         class="CardExampleImg" id="J_CardExample_Img">
                                </p>
                            </div>

                            <div class="col-xs-8 form-group">
                                <div class="col-sm-offset-2 col-sm-10">
                                    <!--<button type="button" class="btn btn-primary" id="step-s21">上一步</button>-->
                                    <button type="button" class="btn btn-default" id="step-s2">下一步</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div id="UploadifiveQueue"></div>
<script src="<%- Virtual_Path.Static %>jquery.plugin/uploadifive/jquery.uploadifive.min.js"></script>
<link rel="stylesheet" href="<%- Virtual_Path.Static %>jquery.plugin/uploadifive/uploadifive.css">
<link rel="stylesheet" href="<%- Virtual_Path.Static %>jquery.plugin/uploadifive/uploadifive.custom.css">
<style>
    .CardExampleImg {
        position: absolute;
        top: -78px;
        left: 310px;
        width: 250px;
    }
</style>
<script>
  $(function () {
    ////////////////////////////////////
    //判断是否登录或者是否申请艺人或公会
    ////////////////////////////////////
    if (_StateData.IsAnchor) {
      $.CommonMain.Modal_Tip('你已经申请了艺人，无需申请了', {
        Timeout: 1000,
        onClose: function () {
          location.href = "/";
        }
      });
    }
    if (_PageData.flag == 2) {
      $.CommonMain.Modal_Tip(_PageData.message, {
        Timeout: 2000,
        onClose: function () {
          location.href = "/";
        }
      });
    }
    ////////////////////////////////////
    //判断PageData
    ////////////////////////////////////
    if (!$.CommonMain.PageDataCheck()) {
      return;
    }
    ////////////////////////////////////
    //身份证上传
    ////////////////////////////////////
    $('#exampleInputFileA').uploadifive({
      'uploadScript': _VirtualPath.Utils + 'service/fileupload',
      'removeCompleted': true,
      'queueID': 'UploadifiveQueue',
      'multi': false,
      'buttonClass': '',
      'buttonText': '身份证(正面)',
      'fileType': 'image/*',
      'onUploadComplete': function (file, data) {
        data = $.parseJSON(data);
        if (data.flag !== 0) {
          $.CommonMain.Modal_Tip("上传文件出错，请重试！", {Timeout: 1000});
          return;
        }
        $.ajax({
          url: "/ajax/base.user-anchoridcard",
          type: "post",
          dataType: "json",
          data: {
            FileName: data.FileName,
            Front: "a"
          },
          success: function (data) {
            $('#J_Status_AImg').empty().append('<input type="hidden" value="1" id="J_Status_Img_A">');
          }
        });
      }
    });
    $('#exampleInputFileB').uploadifive({
      'uploadScript': _VirtualPath.Utils + 'service/fileupload',
      'removeCompleted': true,
      'queueID': 'UploadifiveQueue',
      'multi': false,
      'buttonClass': '',
      'buttonText': '身份证(背面)',
      'fileType': 'image/*',
      'onUploadComplete': function (file, data) {
        data = $.parseJSON(data);
        if (data.flag !== 0) {
          $.CommonMain.Modal_Tip("上传文件出错，请重试！", {Timeout: 1000});
          return;
        }
        $.ajax({
          url: "/ajax/base.user-anchoridcard",
          type: "post",
          dataType: "json",
          data: {
            FileName: data.FileName,
            Front: "b"
          },
          success: function (data) {
            $('#J_Status_BImg').empty().append('<input type="hidden" value="1" id="J_Status_Img_B">');
          }
        });
      }
    });
    var TageInfo = '';
    for (var n = 0; n < _PageData.Banks.Data.length; n++) {
      if (n == 0) {
        TageInfo += '<option value="" checked="">--</option>';
        TageInfo += '<option value="' + _PageData.Banks.Data[n] + '">' + _PageData.Banks.Data[n] + '</option>';
      } else {
        TageInfo += '<option value="' + _PageData.Banks.Data[n] + '">' + _PageData.Banks.Data[n] + '</option>';
      }
    }
    $('#J_Account_BankName').empty().append(TageInfo);
    //切换省份
    $("#region_parent").change(function () {
      var region = {};
      region.Account_Province = $("#region_parent option:selected").val();
      region.Account_City = $.Common.GetRegion(region.Account_Province);
      if (region.Account_City) {
        for (var i = 0; i < region.Account_City.length; i++) {
          if (i == 0) {
            region.TageInfo += '<option value="" checked="">--</option>';
            region.TageInfo += '<option value="' + region.Account_City[i] + '">' + region.Account_City[i] + '</option>';
          } else {
            region.TageInfo += '<option value="' + region.Account_City[i] + '">' + region.Account_City[i] + '</option>';
          }
        }
      }
      $('#region_city').empty().append(region.TageInfo);

    });
    //审核提交
    $('#step-s2').click(function () {
      params = {};
      params.Account_RealName = $.trim($('input[name="Account_RealName"]').val());
      params.Account_CardNo = $.trim($('input[name="Account_CardNo"]').val());
      params.Account_BankName = $.trim($('select[name="Account_BankName"]').val());
      params.Account_BankFullName = $.trim($('input[name="Account_BankFullName"]').val());
      params.IDCard = $.trim($('input[name="IDCard"]').val());
      params.Card_A = $.trim($('#J_Status_Img_A').val());
      params.Card_B = $.trim($('#J_Status_Img_B').val());
      params.Account_Province = $.trim($("#region_parent option:selected").val());
      params.Account_City = $.trim($("#region_city option:selected").val());
      if (!params.Account_RealName) {
        $.CommonMain.Modal_Tip('请输入开户行姓名', {Timeout: 1000});
        $('input[name="Account_RealName"]').focus();
        return false;
      }
      if (!params.Account_BankName) {
        $.CommonMain.Modal_Tip('请选择开户行', {Timeout: 1000});
        return false;
      }
      if (!params.Account_CardNo) {
        $.CommonMain.Modal_Tip('请输入开户行账号', {Timeout: 1000});
        $('input[name="Account_CardNo"]').focus();
        return false;
      }
      if (!params.Account_Province) {
        $.CommonMain.Modal_Tip('请选择省份', {Timeout: 1000});
        return false;
      }
      if (!params.Account_City) {
        $.CommonMain.Modal_Tip('请选择市', {Timeout: 1000});
        return false;
      }
      if (!params.Account_BankFullName) {
        $.CommonMain.Modal_Tip('请输入开户行地址及分行名称', {Timeout: 1000});
        $('input[name="Account_BankFullName"]').focus();
        return false;
      }
      if (!params.IDCard) {
        $.CommonMain.Modal_Tip('请输入身份证号', {Timeout: 1000});
        $('input[name="IDCard"]').focus();
        return false;
      }
      if (params.Card_A != 1) {
        $.CommonMain.Modal_Tip('请上传身份证正面', {Timeout: 1000});
        return false;
      }
      if (params.Card_B != 1) {
        $.CommonMain.Modal_Tip('请上传身份证反面', {Timeout: 1000});
        return false;
      }
      $.KOC.Loading.Open();
      $.ajax({
        url: '/ajax/business.user-anchorapply.steptwo',
        type: 'post',
        dataType: 'json',
        data: {
          Account_RealName: params.Account_RealName,
          Account_CardNo: params.Account_CardNo,
          Account_BankFullName: params.Account_BankFullName,
          Account_BankName: params.Account_BankName,
          IDCard: params.IDCard,
          Account_Province: params.Account_Province,
          Account_City: params.Account_City
        },
        success: function (data) {
          $.KOC.Loading.Close();
          if (data.flag !== 0) {
            $.CommonMain.Modal_Tip(data.msg + "(" + data.flag + ")", {Timeout: 2000});
            return;
          }
          var url = "/entry/anchor/step_3";
          location.href = url;
        }
      });
    });
  });
</script>